﻿using B.S.Filtration.Domain;
using B.S.Filtration.ErrorCode;
using B.S.Filtration.Read.Api.Application.Command.ProcessCommand;
using MediatR;
using SqlSugar;

namespace B.S.Filtration.Read.Api.Application.CommandHander.ProcessHandler
{
    public class GetTypeCommandHandler : IRequestHandler<GetTypeCommand, APIResult<List<ProcessType>>>
    {
        private readonly ISqlSugarClient db;

        public GetTypeCommandHandler(ISqlSugarClient db)
        {
            this.db = db;
        }

        public async Task<APIResult<List<ProcessType>>> Handle(GetTypeCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<ProcessType>> result = new APIResult<List<ProcessType>>();
            result.code = APIResultCode.success;
            result.msg = "查询显示成功";

            var list = db.Queryable<ProcessType>();

            result.data = list.ToList();

            return await Task.FromResult(result);
        }
    } 
}
 